<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>全部员工</title>
<!--  
	SpringMVC 处理静态资源:
	1. 为什么会有这样的问题:
	优雅的 REST 风格的资源URL 不希望带 .html 或 .do 等后缀
	若将 DispatcherServlet 请求映射配置为 /, 
	则 Spring MVC 将捕获 WEB 容器的所有请求, 包括静态资源的请求, SpringMVC 会将他们当成一个普通请求处理, 
	因找不到对应处理器将导致错误。
	2. 解决: 在 SpringMVC 的配置文件中配置 <mvc:default-servlet-handler/>
-->
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/css/allUser.css">
<script type="text/javascript"
	src="${pageContext.request.contextPath}/scripts/jquery-1.9.1.min.js"></script>
<script type="text/javascript">
	$(function() {
		$(".delete").click(function() {
			var href = $(this).attr("href");
			$("form").attr("action", href).submit();
			return false;
		});
	});
</script>
<style type="text/css">
td {
	text-align: center;
}

table tr th {
	border-width: 1px;
	padding: 8px;
	border-style: solid;
	border-color: #666666;
	background-color: #dedede;
}
</style>
</head>
<body>

	<form action="" method="post">
		<input type="hidden" name="_method" value="DELETE" />
	</form>

	<c:choose>
		<c:when test="${empty requestScope.ALLUSER}">
			没有员工信息
		</c:when>
		<c:otherwise>
			<table border="1" height="100%" width="100%" cellspacing="0"
				cellpadding="0" align="center">
				<tr>
				
					<div class="search">
					<form action="${pageContext.request.contextPath }/user/selectByPrimaryKey.action" method="post">
						<input type="text" name="search" id="search" placeholder="请输入关键字">
						<span> <input type="submit" class="submit" value="搜索" id = "seacrh_btn"></span>
					</form>
					</div>


				</tr>

				<tr>
					<th>编号</th>
					<th>姓名</th>
					<th>年龄</th>
					<th>地址</th>
					<th>操作</th>
				</tr>
				<c:forEach items="${requestScope.ALLUSER }" var="UserInfo">
					<tr>
						<td>&nbsp;${UserInfo.userId }&nbsp;</td>
						<td>&nbsp;${UserInfo.userName }&nbsp;</td>
						<td>${UserInfo.userAge }</td>
						<td>${UserInfo.userAddress }</td>
						<td><a class="delete"
							href="${pageContext.request.contextPath }/user/delete/${UserInfo.userId}.action">删除</a>&nbsp;&nbsp;&nbsp;&nbsp;<a
							href="${pageContext.request.contextPath }/user/goUpdateUser/${UserInfo.userId}.action">更新</a></td>
					</tr>
				</c:forEach>
				 <tr>
            <td colspan="6">
            <!-- 分页功能 start -->
            <div align="center">
                <font size="2">共 ${page.totalPageCount} 页</font> <font size="2">第
                ${page.pageNow} 页</font> <a href="${pageContext.request.contextPath}/queryAll?pageNow=1">首页</a>
                <c:choose>
                    <c:when test="${page.pageNow - 1 > 0}">
                        <a href="${pageContext.request.contextPath}/queryAll?pageNow=${page.pageNow - 1}">上一页</a>
                    </c:when>
                    <c:when test="${page.pageNow - 1 <= 0}">
                        <a href="${pageContext.request.contextPath}/queryAll?pageNow=1">上一页</a>
                    </c:when>
                </c:choose>
                <c:choose>
                    <c:when test="${page.totalPageCount==0}">
                        <a href="${pageContext.request.contextPath}/queryAll?pageNow=${page.pageNow}">下一页</a>
                    </c:when>
                    <c:when test="${page.pageNow + 1 < page.totalPageCount}">
                        <a href="${pageContext.request.contextPath}/queryAll?pageNow=${page.pageNow + 1}">下一页</a>
                    </c:when>
                    <c:when test="${page.pageNow + 1 >= page.totalPageCount}">
                        <a href="${pageContext.request.contextPath}/queryAll?pageNow=${page.totalPageCount}">下一页</a>
                    </c:when>
                </c:choose>
                <c:choose>
                    <c:when test="${page.totalPageCount==0}">
                        <a href="${pageContext.request.contextPath}/queryAll?pageNow=${page.pageNow}">尾页</a>
                    </c:when>
                    <c:otherwise>
                        <a href="${pageContext.request.contextPath}/queryAll?pageNow=${page.totalPageCount}">尾页</a>
                    </c:otherwise>
                </c:choose>
            </div>
            <!-- 分页功能 End -->
            </td>
        </tr>
			</table>

		</c:otherwise>
	</c:choose>
</body>
</html>